package com.suke.czx.modules.tb.controller;

import java.util.Map;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.suke.czx.modules.tb.entity.TbUserFavorite;
import com.suke.czx.modules.tb.service.TbUserFavoriteService;
import com.suke.zhjg.common.autofull.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import com.suke.czx.common.annotation.SysLog;
import com.suke.czx.common.base.AbstractController;


/**
 * 用户收藏表 (多对多)
 *
 * @author developer
 * @email developer@163.com
 * @date 2025-05-17 21:49:36
 */
@RestController
@AllArgsConstructor
@RequestMapping("/tb/userFavorite")
@Api(value = "TbUserFavoriteController", tags = "用户收藏表 (多对多)")
public class TbUserFavoriteController extends AbstractController {
    private final TbUserFavoriteService tbUserFavoriteService;

    /**
     * 列表
     */
    @ApiOperation(value = "用户收藏表 (多对多)列表")
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        //查询列表数据
        QueryWrapper<TbUserFavorite> queryWrapper = new QueryWrapper<>();
        final String keyword = mpPageConvert.getKeyword(params);
        if (StrUtil.isNotEmpty(keyword)) {

        }
        IPage<TbUserFavorite> listPage = tbUserFavoriteService.page(mpPageConvert.<TbUserFavorite>pageParamConvert(params), queryWrapper);
        return R.ok().setData(listPage);
    }


    /**
     * 新增用户收藏表 (多对多)
     */
    @ApiOperation(value = "新增用户收藏表 (多对多)数据")
    @SysLog("新增用户收藏表 (多对多)数据")
        @PostMapping()
        public R save(@RequestBody TbUserFavorite tbUserFavorite) {
        tbUserFavoriteService.save(tbUserFavorite);
        return R.ok();
    }


    /**
     * 修改
     */
    @ApiOperation(value = "修改用户收藏表 (多对多)数据")
    @SysLog("修改用户收藏表 (多对多)数据")
        @PutMapping()
        public R update(@RequestBody TbUserFavorite tbUserFavorite) {
        tbUserFavoriteService.updateById(tbUserFavorite);
        return R.ok();
    }


    /**
     * 删除
     */
    @ApiOperation(value = "删除用户收藏表 (多对多)数据")
    @SysLog("删除用户收藏表 (多对多)数据")
        @DeleteMapping()
        public R delete(@RequestBody TbUserFavorite tbUserFavorite) {
        tbUserFavoriteService.removeById(tbUserFavorite.getId());
        return R.ok();
    }

}
